<?php
    /**
     * Created by PhpStorm
     * User: y.
     * Email: 707186758@qq.com
     * Date: 2023/3/2
     * Time: 14:28
     */

    namespace app\common\service;

    use app\admin\model\Baseconfig as BaseConfigModel;
    use Hedeqiang\TenIM\IM;
    use WeChat\Oauth;
    use WeChat\Pay;
    use WeMini\Crypt;
    use think\Db;
    
    class Base
    {
        public array $config;

        protected IM $im;
        
        public function __construct()
        {
            $this->config = Db::name("base_config")->column('data','name');


            $configFiled = [];
            if (!empty($this->config['appId'])) $configFiled['appid'] = $this->config['appId'];
            if (!empty($this->config['appSecret'])) $configFiled['appsecret'] = $this->config['appSecret'];
            if (!empty($this->config['encodingAeskey'])) $configFiled['encodingaeskey'] = $this->config['encodingAeskey'];
            if (!empty($this->config['mchId'])) $configFiled['mch_id'] = $this->config['mchId'];
            if (!empty($this->config['mchKey'])) $configFiled['mch_key'] = $this->config['mchKey'];
            if (!empty($this->config['sslKey'])) $configFiled['ssl_key'] = $this->config['sslKey'];
            if (!empty($this->config['sslCer'])) $configFiled['ssl_cer'] = $this->config['sslCer'];
            

            
            // 微信支付
            // $this->wechat = new Pay($configFiled);
            
            // IM
            $imConfig = [
                'sdk_app_id' => $this->config['tencentIMSdkAppId'],
                'secret_key' => $this->config['tencentIMSdkAppkey'],
                'identifier' => $this->config['tencentIMIdentifier'],
            ];
          
            $this->im = new IM($imConfig);
    
            
        }
    }
